/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "error_type")
@NamedQueries({
    @NamedQuery(name = "ErrorType.findAll", query = "SELECT e FROM ErrorType e"),
    @NamedQuery(name = "ErrorType.findByErrorId", query = "SELECT e FROM ErrorType e WHERE e.errorId = :errorId"),
    @NamedQuery(name = "ErrorType.findByErrorType", query = "SELECT e FROM ErrorType e WHERE e.errorType = :errorType"),
    @NamedQuery(name = "ErrorType.findByErrorLevel", query = "SELECT e FROM ErrorType e WHERE e.errorLevel = :errorLevel")})
public class ErrorType implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "error_id")
    private Integer errorId;
    @Basic(optional = false)
    @Column(name = "error_type")
    private String errorType;
    @Basic(optional = false)
    @Column(name = "error_level")
    private int errorLevel;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "errorType", fetch = FetchType.LAZY)
    private List<ErrorMiddle> errorMiddleList;

    public ErrorType() {
    }

    public ErrorType(Integer errorId) {
        this.errorId = errorId;
    }

    public ErrorType(Integer errorId, String errorType, int errorLevel) {
        this.errorId = errorId;
        this.errorType = errorType;
        this.errorLevel = errorLevel;
    }

    public Integer getErrorId() {
        return errorId;
    }

    public void setErrorId(Integer errorId) {
        this.errorId = errorId;
    }

    public String getErrorType() {
        return errorType;
    }

    public void setErrorType(String errorType) {
        this.errorType = errorType;
    }

    public int getErrorLevel() {
        return errorLevel;
    }

    public void setErrorLevel(int errorLevel) {
        this.errorLevel = errorLevel;
    }

    public List<ErrorMiddle> getErrorMiddleList() {
        return errorMiddleList;
    }

    public void setErrorMiddleList(List<ErrorMiddle> errorMiddleList) {
        this.errorMiddleList = errorMiddleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (errorId != null ? errorId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ErrorType)) {
            return false;
        }
        ErrorType other = (ErrorType) object;
        if ((this.errorId == null && other.errorId != null) || (this.errorId != null && !this.errorId.equals(other.errorId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.ErrorType[errorId=" + errorId + "]";
    }

}
